package com.company.queue;

public class CricleArrayDemo {
    public static void main(String[] args) {

    }
}
class CricleArray{
    private int maxSize;    //数组的最大容量
    private int front;      //队列头,指向第一个元素
    private int rear;       //队列尾，指向最后一个元素的后一位
    private int[] arr;      //存储数据

    public CricleArray(int maxSize, int front, int rear, int[] arr) {
        this.maxSize = maxSize;
        this.front = front;
        this.rear = rear;
        this.arr = arr;
    }

    public boolean isFull(){
        return (rear+1)%maxSize==front;
    }

    public void addQueue(int n){
        if (isFull()){
            throw new RuntimeException("加入元素失败！队列已满！");
        }
        arr[rear]=n;
        rear=(rear+1)%maxSize;
    }

    

}